package thinkingInJava.io;
// page 540
//: io/BufferedInputFile.java
import java.io.*;

public class BufferedInputFile {
	// Throw exceptions to console:
	public static String
	read(String filename) throws IOException {
		// Reading input by lines:
		BufferedReader in = new BufferedReader(
				new FileReader(filename));
		String s;
		StringBuilder sb = new StringBuilder();
		while((s = in.readLine())!= null)
			sb.append(s + "\n");	// readLine 会去掉换行
		in.close();	// 这个必须显示调用
		return sb.toString();
	}
	public static void main(String[] args)
			throws IOException {
		System.out.print(read("BufferedInputFile.java"));
	}
} /* (Execute to see output) *///:~
